<template>
    <message-table :data-source="tableList" :wx_id="$store.state.on_line_weChat_id">
        <template slot="body" slot-scope="props">
            <div class="feed-element">
                <!--<a href="javascript:;" class="pull-left">-->
                    <!--<checkbox-->
                        <!--:value = "props.item.id"-->
                        <!--v-model="stateManager.selectModelID"-->
                        <!--&gt;-->
                <!--</checkbox></a>-->
                <a target="_blank" :href="props.item.headimgurl" class="pull-left">
                    <img alt="image" class="img-circle" :src="urlCheck(props.item.headimgurl)">
                </a>
                <div class="media-body ">
                    <small class="pull-right"></small>
                    <strong>{{props.item.nick_name}}</strong>---<strong>{{props.item.wechat.nick_name}}</strong><br>
                    <small class="text-muted">{{props.item.created_at}}</small><br>
                    <small class="text-muted">备注： {{props.item.remark}}</small>
                    <!--<div class="well" v-html="changeContent(props.item.content)" v-if="props.item.content !== null">-->
                        <!--{{changeContent(props.item.content)}}-->
                    <!--</div>-->
                    <div class="pull-right">
                        <button v-on:click="showDialog(props.item.id)" class="btn btn-xs btn-primary"><i class="fa fa-pencil"></i> 修改备注</button>
                    </div>
                </div>
            </div>
        </template>
    </message-table>
</template>

<script>
    export default {
        props: {
            stateManager: {
                type: Object
            }
        },
        data: function () {
            return {
                list: this.$listDataSource({
                    url:'api/WeChat/WeChatUser',
                }),
//                ReturnArr: {'0': '未回复', '1': '已回复'},
            };
        },
        methods: {
            showDialog: function (uuid) {
                this.stateManager.SeeDialogVisible = true;
                this.stateManager.SeeModelId = uuid;
            },
            changeTime:function (time) {
                return new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
            },
            showDeleteDialog: function (uuid) {
                this.stateManager.deleteDialogVisible = true;
                this.stateManager.deleteModelId = uuid;
            },
            urlCheck:function (url) {
                if(url){
                    return url
                }else{
                    return 'http://tjise.daxuefun.cn/images/failed.png'
                }
            },
        },
        computed: {
            user(){
                return this.$store.state.user;
            },

            tableList(){
                if (this.stateManager.refreshList) {

                    this.list.fetch();
                    this.stateManager.refreshList = false;
                }
                return this.list;
            }
        }
    }
</script>